import socket

host = ''
port = 2000
s = socket.socket()
s.bind((host, port))
while True:
    s.listen(5)
    conntection, address = s.accept()
    request = conntection.recv(1024)
    print('ip and request,{}\n{}'.format(address, request.decode('utf-8')))
    response = b'<h1>Hello world!</h1>'
    conntection.sendall(response)
    conntection.close()

'''
ip and request,('127.0.0.1', 1024)
GET / HTTP/1.1
Host: localhost:2000
Connection: keep-alive
Cache-Control: max-age=0
sec-ch-ua: "Chromium";v="94", "Google Chrome";v="94", ";Not A Brand";v="99"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Windows"
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.61 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Sec-Fetch-Site: none
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Sec-Fetch-Dest: document
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9
'''